#include <bits/stdc++.h>
using namespace std;
int t, n, m, p[100010];
double l, V, d[100010], v[100010], a[100010], o[100010], oe[100010];

int main() {
	freopen ("detect.in", "r", stdin);
	freopen ("detect.out", "w", stdout);
	for (cin >> t; t--;) {
		memset (o, -1, sizeof o);
		cin >> n >> m >> l >> V;
		for (int i = 1; i <= n; i++)
			cin >> d[i] >> v[i] >> a[i];
		for (int i = 1, x; i <= m; i++) {
			cin >> x;
			p[x] = 1;
		}
		for (int i = 1; i <= l; i++)
			p[i] += p[i - 1];
		for (int i = 1; i <= n; i++)
			if (a[i] > 0) {
				if (v[i] > V)
					o[i] = d[i];
				else
					o[i] = (V * V - v[i] * v[i]) / (2 * a[i]);
				oe[i] = l;
			} else if (a[i] < 0) {
				if (v[i] > V) {
					o[i] = d[i];
					oe[i] = (V * V - v[i] * v[i]) / (2 * a[i]);
				}
			} else if (v[i] > V) {
				o[i] = d[i];
				oe[i] = l;
			}
		int cnt = 0;
		for (int i = 1; i <= n; i++)
			if (o[i] + 1 && p[int (oe[i])] - p[int (o[i])] > 0) cnt++;
		cout << cnt << ' ' << cnt << '\n';
	}
	return 0;


}
